<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="./css/login.css">
    <script src="js/login.js"></script>
    <script src="http://code.jquery.com/jquery-latest.js"></script>

</head>
<body>

<!-- 搭建结构 -->
<div class="container switch">
    <!-- 注册页面 -->
    <div class="container-form container-signup">
        <form action="" class="form">
            <h2 class="form-title">Sign Up</h2>
            <input type="text" placeholder="User" class="input">
            <input type="email" placeholder="Email" class="input">
            <input type="password" placeholder="Password" class="input">
            <button class="submit">sign up</button>
        </form>
    </div>
    <!-- 登录页面 -->
    <div class="container-form container-signin">
        <form action="javascript:void(0);" class="form">
            <h2 class="form-title">Sign In</h2>

            <td><input id="snoIpt" type="text" class="input"  placeholder="User"></td>
            <td><input id="stukeyIpt" type="password" class="input"  placeholder="Password"></td>
            <td><input id="checkCodeIpt" type="text"  class="input"  placeholder="Verification"></td>
            <td><img id="checkCode" src="/RuanJianKeShe/checkCode"></td>

            <a href="javascript:void(0);">forgot your password?</a>
            <input onclick="login()" type="button" value="sign in" class="submit">
        </form>
    </div>
    <!-- 覆盖层 -->
    <div class="container-overlay">
        <div class="overlay">
            <div class="overlay-slide overlay-left">
                <button class="submit" id="goSignIn">sign in</button>
            </div>
            <div class="overlay-slide overlay-right">
                <button class="submit" id="goSignUp">sign up</button>
            </div>
        </div>
    </div>
</div>

</body>
<script>

    var img = document.getElementById("checkCode")
    img.onclick = function () {
        updatecheck();
    }
    updatecheck = function () {
        var date = new Date().getTime();
        img.src = "/RuanJianKeShe/checkCode?"+date;
    }
    login = function () {
        $.ajax({
            url:"/RuanJianKeShe/loginStu",
            type:"post",
            data:{
                "msg":"loginStu",
                "sno":$("#snoIpt").val(),
                "stukey":$("#stukeyIpt").val(),
                "checkCode":$("#checkCodeIpt").val(),
            },
            dataType:"json",
            success:function(info){
                alert(info.checkInfo);
                updatecheck();
            },
            error:function(){
                window.location.href="student.html"
            }
        })
    }
</script>
</html>